{extend name="layout" /}
{block name="content"}
<div class="table-margin">
    <form action="{:url('user/useradd')}" class="form-horizontal" method="post">
        <table class="table table-bordered contact-template-form">
            <tbody>
            <tr>
                <td width="20%" align="right"><font color="red">*</font>管理组：</td>
                <td>
                    <select name="role_id" class="form-control">
                        {foreach name="role" item="r"}
                            <option value="{$r.id}">{$r.role_name}</option>
                        {/foreach}
                    </select>
                </td>
            </tr>
            <tr>
                <td width="20%" align="right"><font color="red">*</font>登陆账号：</td>
                <td>
                    <input class="form-control" type="text" name="user_name" required="" aria-required="true">
                </td>
            </tr>
            <tr>
                <td width="20%" align="right"><font color="red">*</font>登陆密码：</td>
                <td>
                    <input class="form-control" type="text" name="password" required="" aria-required="true">
                </td>
            </tr>
            <tr>
                <td width="20%" align="right"><font color="red">*</font>真实姓名：</td>
                <td>
                    <input class="form-control" type="text" name="real_name" required="" aria-required="true">
                </td>
            </tr>
            <tr>
                <td width="20%" align="right"><font color="red">*</font>管理员联系方式：</td>
                <td>
                    <input class="form-control" type="text" name="phone" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onpaste="this.value=this.value.replace(/[^\d]/g,'')" required="" aria-required="true">
                </td>
            </tr>
            <tr>
                <td width="20%" align="right">管理员邮箱：</td>
                <td>
                    <input class="form-control" type="text" name="email">
                </td>
            </tr>
            <tr>
                <td width="20%" align="right">状态：</td>
                <td>
                    {foreach name="Think.config.user_status" item="s"}
                    <label>
                        <input class="xb-icheck" type="radio" name="status" {$key==1?='checked'} value="{$key}">
                        <span class="pull-right">&nbsp;{$s}&nbsp;&nbsp;&nbsp;&nbsp;</span>
                    </label>
                    {/foreach}
                </td>
            </tr>
            <tr>
                <tD></td>
                <td>
                    <input class="btn btn-primary" type="submit" value="添加">
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        $('form').submit(function(){
            $(this).ajaxSubmit({
                success:function(res) {
                    if(1 == res.code){
                        layer.alert('添加成功！', {icon: 1});
                        history.go(-1);
                    }else{
                        layer.alert(res.msg, {icon:2});
                    }
                }
            });
            return false;
        });
    });
</script>
{/block}